from aiogram.types import CallbackQuery
from aiogram.dispatcher import FSMContext
from keyboards.subjects import create_subjects_keyboard
from services.fipi import list_subjects
from states import QuestionState


async def select_exam_callback_handler(callback_query: CallbackQuery, state: FSMContext):
    exam_type = callback_query.data.split(":")[0]

    async with state.proxy() as data:
        data["exam_type"] = exam_type

    await QuestionState.next()

    subjects = await list_subjects()
    keyboard = create_subjects_keyboard(subjects)

    await callback_query.message.answer("Выбери предмет:", reply_markup=keyboard)
